package repository

import (
	"context"
	"gitee.com/flycash/ai-gateway-demo/internal/domain"
	"gitee.com/flycash/ai-gateway-demo/internal/repository/dao"
)

type PromptConfigRepo interface {
	FindPromptByKey(ctx context.Context, key string) (domain.PromptTemplate, error)
}

type promptConfigRepo struct {
	pdao dao.PromptDAO
}

func NewPromptConfigRepo(pdao dao.PromptDAO)PromptConfigRepo {
	return &promptConfigRepo{
		pdao: pdao,
	}
}

func (p *promptConfigRepo) FindPromptByKey(ctx context.Context, key string) (domain.PromptTemplate, error) {
	pro, err := p.pdao.FindPromptByKey(ctx, key)
	if err != nil {
		return domain.PromptTemplate{}, err
	}
	return domain.PromptTemplate{
		ID:        pro.ID,
		PromptKey: pro.PromptKey,
		Template:  pro.Template,
		Ctime:     pro.Ctime,
		Utime:     pro.Utime,
	}, nil
}
